package other;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class TestFrame extends JFrame {

	private LoginPanel panel;
	
	public TestFrame()
	{
		// Set title.
		this.setTitle("Hotel Management System");
		
		// Set frame location to center.
		this.setLocationRelativeTo(null);
		
		// Set size.
		this.setExtendedState(MAXIMIZED_BOTH);
		
		// Set close operation.
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		panel = new LoginPanel();
		this.add(panel);
	}

	public void open()
	{
		this.setVisible(true);
	}


	public static void main(String [] args)
	{
		TestFrame frame = new TestFrame();
		frame.open();
	}
}

class LoginPanel extends JPanel 
{
	private BufferedImage img = null;
	Dimension screenSize;
	
	public LoginPanel()
	{
		Toolkit tk = Toolkit.getDefaultToolkit();
		screenSize = tk.getScreenSize();
		
		this.getImage();
	}
	
	public void getImage()
	{
		try {
			img = ImageIO.read(new File("images/title.jpg"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void paint(Graphics g)
	{
		int x = (getWidth()-img.getWidth())/2;
		int y = 0;
		
		g.drawImage(img, x, y, null);
	}
}